package com.example.travel_front.Activity;

import android.content.Intent;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.example.travel_front.R;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

public class LoginActivity extends AppCompatActivity {

    private EditText emailInput;
    private EditText passwordInput;
    private Button signInButton;
    private Button createAccountButton;
    private ImageView facebookButton;
    private ImageView twitterButton;
    private ImageView googleButton;
    private TextView termsPrivacyPolicy;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login); // Replace with your actual layout name

        // Initialize views
        emailInput = findViewById(R.id.emailInput);
        passwordInput = findViewById(R.id.passwordInput);
        signInButton = findViewById(R.id.signInButton);
        createAccountButton = findViewById(R.id.createAccountButton);
        facebookButton = findViewById(R.id.facebookButton);
        twitterButton = findViewById(R.id.twitterButton);
        googleButton = findViewById(R.id.googleButton);
        termsPrivacyPolicy = findViewById(R.id.termsPrivacyPolicy);

        // Setup listeners
        setupListeners();
    }

    private void setupListeners() {
        signInButton.setOnClickListener(view -> {
            // Handle sign in
            performSignIn();
        });

        createAccountButton.setOnClickListener(view -> {
            // Navigate to create account screen or handle it here
            navigateToCreateAccount();
        });

        facebookButton.setOnClickListener(view -> {
            // Handle Facebook sign in
        });

        twitterButton.setOnClickListener(view -> {
            // Handle Twitter sign in
        });

        googleButton.setOnClickListener(view -> {
            // Handle Google sign in
        });

        termsPrivacyPolicy.setOnClickListener(view -> {
            // Handle click on Terms & Privacy Policy
        });
    }

    private void performSignIn() {
        // Implement your sign-in logic here
        String email = emailInput.getText().toString();
        String password = passwordInput.getText().toString();
        Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
        startActivity(intent);

        // Optionally, finish the current activity if you don't want to return to it
        finish();
    }

    private void navigateToCreateAccount() {
        // Navigate to the account creation activity or handle it in a dialog/fragment
        Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
        startActivity(intent);
    }
}
